/** * Reverses the characters of a string. * * @param {string} s - The string to reverse. * @returns {string} The reversed string. * @throws {TypeError} If the input is not a string. */ export function reverse(s) { if (typeof s !== "string") { throw new TypeError("Input must be a string"); } // An empty string will naturally return an empty string. return s.split("").reverse().join(""); }